

document.write("<script src=\"" + context+ "/app/log/js/xflog.js\"></script>");

/**
 * render column overwrite querylist4ext.js
 * 
 * @param {}
 *            value
 * @param {}
 *            cellmeta
 * @param {}
 *            record
 * @param {}
 *            rowIndex
 * @param {}
 *            columnIndex
 * @param {}
 *            store
 * @return {}
 */
function renderHeader(value, cellmeta, record, rowIndex, columnIndex, store) {
	var fieldName = Ext.getCmp(querykey).getColumnModel()
			.getDataIndex(columnIndex);
	if (fieldName == 'LFBS') {
		var resultString = String
				.format(
						'<b><a href="'
								+ context
								+ '/system/objectcreator.do?method=view&key=APP_LFDJ&id={0}">查阅</a></b>',
						record.data.ID, value);
		return resultString;
	} else if (fieldName == 'SJGZ') {
		
		resultString = String.format(
							'<b><a href="javascript:showLogWin(\'{0}\')">查看</a></b>',
							record.data.ID, value);

		return resultString;
	}else if (fieldName == 'XFTIME') {
		return formatDate(value);
	}else if(fieldName == 'XJTIME'){
		//var now = new Date().pattern("yyyyMMdd"); 
		var now = new Date().pattern("MM-dd-yyyy"); 
		f = value.substring(0, 4);
		m = value.substring(5, 7);
		e = value.substring(8, 10);
		var xjtime = m+"-"+e+"-"+f ;
		
		var xftime = "";
		if(record.data.XFTIME!=null){
			var total_time = record.data.XFTIME;
			var a = total_time.substring(0, 4);
			var b = total_time.substring(4, 6);
			var c = total_time.substring(6, 8);
			xftime = b+"-"+c+"-"+a ;
			
		}
		//alert("xjtime = " + xjtime);
		if(record.data.LFSTATUS!='1'){
			if (Date.parse(xjtime) - Date.parse(now)<= 0) {
			
			return "<div align='center'><img src='"
					+ context
					+ "/app/lf/images/lamp3.gif'  style='margin-bottom:-4px'/></div>" ;
			}else if (Date.parse(xjtime) - Date.parse(now)  >= 15*1000*60*60*24) {
			return "<div align='center'><img src='"
					+ context
					+ "/app/lf/images/lamp4.gif'  style='margin-bottom:-4px'/></div>" ;
			}else{
					
					if(xftime!=""){
						
						if(Date.parse(xjtime) - Date.parse(now)<=(Date.parse(xjtime) - Date.parse(xftime))/2){
							return "<div align='center'><img src='"
								+ context
								+ "/app/lf/images/lamp2.gif'  style='margin-bottom:-4px'/></div>" ;
						}else{
							return "<div align='center'><img src='"
									+ context
									+ "/app/lf/images/lamp4.gif'  style='margin-bottom:-4px'/></div>" ;
						}
					}else{
						return "<div align='center'><img src='"
								+ context
								+ "/app/lf/images/lamp2.gif'  style='margin-bottom:-4px'/></div>" ;
					}
			}
		}else{
			return '';
		}
		
		return now;
	} else if (fieldName == 'LFSTATUS') {
		if (value == '0') {
			return '否';
		} else if (value == '1') {
			return '是';
		}
	} else if (fieldName == 'BLSTATUS') {
		if (value == '0') {
			return '待处理';
		} else if (value == '1') {
			return '自处理';
		} else if (value == '2') {
			return '科室办理';
		} else if (value == '3') {
			return '上报处理';
		} else if (value == '-1') {
			return '未予办理';
		}
	}else if(fieldName == 'LFID'){
		if(judge_role){
			if(record.data.LFSTATUS=='1' || record.data.LFBS=='1'){
				resultString = "删除";
			}else{
				resultString = String.format(
								'<b><a href="javascript:removeItemFromDB_lf('+record.data.LFID+',\'APP_LF\')">删除</a></b>',
								record.data.ID, value);
			}
		}else{
			resultString="";
		}
		
		return resultString;
	}else if (fieldName == 'TS_LFID') {
		if(judge_role && (value=="" || value==null)){
			if(record.data.LFBS!='1'){
				if(record.data.LFSTATUS=='1'){
					resultString = "生成页面";
				}else{
					
						resultString = String
						.format(
								'<b><a href="'
										+ context
										+ '/app/lfbl.do?method=lfneu&id={0}&querykey=' + querykey + '&type=0">生成页面</a></b>',
								record.data.ID, value);
					
				}
			}else{
				resultString = "此为合成记录";
			}
		}else{
			resultString="";
		}
		
		return resultString;
	}
	return value;
}

/**
 * 删除多数据项
 * 
 * @param {}
 *            id 主键ID
 * @param {}
 *            tableName 所属表名称
 */
function removeItemFromDB_lf(id, tableName) {
	
	var url = context + '/system/objectcreator.do?method=deleteitem';
	Ext.MessageBox.confirm('提示', '确定删除?', function(e) {
		if(e=='yes'){
			Ext.MessageBox.wait('删除过程中...');
		    Ext.Ajax.request({
						url : url,
						params : {
							id : id,
							tableName : tableName
						},
						method : 'POST',
						success : function(rs, request) {
							window.location.href = context + '/system/objquery/commonlist.jsp?queryKey=jxlfdjlist';
						},
						failure : function(rs, request) {
							Ext.Msg.alert('提示', '删除数据操作出现异常');
						}
					});
		}
	});
}